• Monday, September 2, 2024

    Generators in JavaScript are special functions that allow you to pause and resume execution, making them ideal for controlling when data is processed. They are especially useful for handling large datasets, asynchronous tasks, and complex iteration patterns.

  • Wednesday, April 3, 2024

    This blog post shows how to use promises in JavaScript to enable non-blocking async tasks. It breaks down the process from start to finish. Promises can trigger an asynchronous action if a handler is attached by either then or catch. Since the handlers are pushed to the Microtask Queue, you can handle the eventual result in a non-blocking way. This makes it easier to handle errors, chain multiple operations together, and keep your code more readable.

  • Tuesday, August 20, 2024

    The parallel-dom npm package offloads heavy DOM operations to parallel iframes for faster rendering. It supports both plain JavaScript and React.

  • Tuesday, July 9, 2024

    This article explores how to simulate millions of particles in JavaScript, achieving a smooth 60 frames per second using only the CPU, particularly focusing on optimization for mobile devices. The author details their process, which involved several iterations, starting with a basic multi-threaded approach using web workers and SharedArrayBuffers. They faced challenges like flickering and performance bottlenecks in rendering and data transfer. To improve performance, they implemented strategies like double buffering and a particle grid count.

  • Wednesday, July 10, 2024

    Parallel DOM makes your web apps faster by parallelizing away heavy DOM operations.

  • Tuesday, June 4, 2024

    Promises in JavaScript aren't always intuitive to use, but they're required to be productive with JavaScript. Promises are needed because JavaScript is single-threaded, which can cause issues when blocking operations like window.prompt() are used. This post dives into the mechanics of Promises, their states (pending, fulfilled, rejected), and how to work with them using the .then() and .catch() methods. It also covers creating custom Promises, chaining them together, passing data between them, and the modern async/await syntax for a more synchronous-like experience.

  • Wednesday, July 3, 2024

    Million.js is a minimalistic JavaScript compiler that improves React's performance by reducing memory usage and enhancing rendering speed through a granular approach to DOM updates. It uses optimized higher-order components called blocks to achieve these performance gains.

  • Friday, August 2, 2024

    There are common myths about how Google handles JavaScript during the indexing process. Through a study involving over 100,000 Googlebot fetches, researchers found that Google can render and index JavaScript content, including complex SPAs, dynamically loaded content, and streamed content. The study also debunked the myth of a significant rendering queue, showing that most pages are rendered within minutes, not days or weeks. As a result, people should feel free to use JS frameworks in their websites while still making sure that pages load fast.

  • Wednesday, July 3, 2024

    Optimizing JavaScript code for performance often involves trade-offs with readability. Careful benchmarking is necessary to identify bottlenecks and measure improvements. Common optimization techniques include avoiding string comparisons and different object shapes, minimizing the use of array and object methods, reducing indirection, and optimizing memory access patterns. Using eval() strategically and understanding the nuances of string manipulation can lead to better performance.

  • Wednesday, July 24, 2024

    Ruby methods are "colorless," meaning there's no distinction between synchronous and asynchronous methods, allowing for asynchronous behavior without explicit markers. Ruby achieves this through independent call stacks, enabled by Threads and Fibers, which allow for switching between tasks without blocking the main thread. This concurrency model, similar to Go's, allows for efficient handling of blocking operations like file reading, HTTP calls, and database queries.

    Md Impact
  • Wednesday, March 20, 2024

    Worker threads provide a way to create independent JavaScript execution threads that run in parallel. This post walks through an example of offloading CPU-intensive tasks to a worker thread in Node.js. Without offloading, tasks can block the event loop and prevent the server from processing other requests. The article shows an example of the server going from processing 7.3k requests to 0 tasks due to a CPU-intensive task.

  • Friday, September 13, 2024

    This article explains the difference between concurrency and parallelism, how they are implemented in JavaScript, and the potential pitfalls of using them in Node.js.

  • Friday, June 14, 2024

    Async programming can make Ruby on Rails apps faster by delaying non-essential tasks and parallelizing I/O-bound operations. This can be achieved using methods like `deliver_later` for emails, `load_async` for database queries, and `dependent: :destroy_async` for dependent associations. However, while async can speed up apps, it can also add complexity, so it's better to address basic performance issues first and use async judiciously.

  • Wednesday, July 31, 2024

    While using useEffect for data fetching is common, it can lead to several issues, including race conditions, out-of-order responses, and inconsistent UI states. Remix's loader function, which provides built-in request cancellation, race condition prevention, and a smooth user experience, handles data fetching seamlessly. It also allows for custom loading states and provides flexibility and control over the user interface. Remix also has pre-rendering capabilities that deliver pre-rendered HTML with data included.

  • Wednesday, May 15, 2024

    The Asynchronous State Handler pattern improves UX in web apps by decoupling data fetching from the UI. It wraps asynchronous queries with meta-queries that track the status (loading, success, error) of the data fetching process. This allows the UI to react dynamically to these states, displaying loading indicators or error messages when needed. The pattern can be implemented in React using a custom hook.

  • Tuesday, March 19, 2024

    Under the hood, async/await is built on promises, where the async function returns a promise that represents the eventual result. The event loop handles promise resolution by tracking promises and resuming suspended processes when promises are fulfilled. There’s a notion that async/await is inherently non-blocking, but that’s not true, as shown by a code example within this article.

    Hi Impact
  • Tuesday, May 14, 2024

    JavaScript has changed a lot since 2015, especially thanks to improvements in the ECMAScript specification. Early JavaScript was difficult to work with due to issues like function-scoped variables and callback hell. Modern JavaScript has introduced features like block-scoped variables, arrow functions, promises, and async/await, which makes development much better. Tooling has also gotten better.

    Hi Impact
  • Friday, June 28, 2024

    Google Sheets initially used a Java-based calculation engine, but later switched to JavaScript for browser-based calculations. Due to performance limitations of JavaScript compared to Java, Google used WasmGC, an extension to WebAssembly that allows for efficient compilation of garbage-collected languages like Java. The initial prototype was slower than JavaScript, but optimizations like replicating JVM/V8 optimizations, using browser APIs, and making code more platform-agnostic resulted in huge performance improvements.

  • Thursday, August 1, 2024

    Coding forms is rarely a value-add activity. Instead, use SurveyJS UI components to generate and style dynamic JSON-based forms of any complexity, right in your JavaScript application — no need for manual coding. The libraries use JSON objects for both form metadata and results, and support seamless integration with any backend system. Render your custom forms, collect responses, and stay fully in control of your data. The JSON form builder component offers a user-friendly drag-and-drop interface, GUI for form branching, and an integrated CSS theme editor for customizing form design. Try it yourself with a fully-featured demo.

    Hi Impact
  • Monday, July 1, 2024

    JavaScript bundles on modern websites are much bigger than they need to be, even for simple functionalities. Popular websites, like ChatGPT and YouTube, have a high amount of client-side JavaScript bloat that doesn't always match the functionality the page offers. Certain websites, like adult websites, prioritize fast loading speeds and have small JavaScript bundles.

  • Tuesday, July 2, 2024

    JavaScript bundles on modern websites are much bigger than they need to be, even for simple functionalities. Popular websites, like ChatGPT and YouTube, have a high amount of client-side JavaScript bloat that doesn't always match the functionality the page offers. Certain websites, like adult websites, prioritize fast loading speeds and have small JavaScript bundles.

  • Monday, March 11, 2024

    Coroutines are functions that can be suspended and resumed while potentially passing data between suspension points. They are useful for implementing various patterns involving cooperation between different tasks or functions, such as asynchronous flows. This article demonstrates how to use coroutines to build a very flexible and simple abstraction for UI components, enabling you to split behavior and view into reusable bits, maintain internal state, and consolidate component lifecycles within a single location.

  • Thursday, April 25, 2024

    A list of various JavaScript engines and libraries for real-time 2D and 3D graphics in web browsers.

  • Thursday, October 3, 2024

    TinyJS is a lightweight JavaScript library designed to facilitate the dynamic creation of HTML elements. It streamlines the process of manipulating the Document Object Model (DOM) by allowing developers to generate standard HTML tags programmatically, apply properties, append content, and select DOM elements with ease. One of the key features of TinyJS is its ability to dynamically create HTML elements. Users can generate any standard HTML tag effortlessly, which is particularly useful for building user interfaces. The library also supports deep property assignment, enabling developers to work with nested property structures for more complex elements. Additionally, it simplifies content appending by accepting both strings and elements as child content, making it versatile for various use cases. TinyJS introduces two helper functions for DOM selection: the `$` function, which acts as a wrapper around `document.querySelector`, and the `$$()` function, which wraps `document.querySelectorAll` and returns an array of DOM elements. This allows for straightforward element selection and iteration, enhancing the overall usability of the library. To illustrate its functionality, an example is provided where a `div` element is created with specific attributes and child elements, such as an `h1` and a `p`. This demonstrates how TinyJS can be used to generate and manipulate HTML elements dynamically. For installation, users simply need to include the `tiny.js` script in their project. Once included, they can utilize any valid HTML tag as a function to create elements, assign properties, and append children to the DOM. An advanced example showcases how properties can be deeply assigned to elements, such as styling a button directly through its properties. TinyJS supports a wide range of HTML tags, including basic text elements, interactive elements, media elements, and container elements, making it a comprehensive tool for web development. The library encourages contributions from the community, asking users to open an issue before submitting a pull request. Overall, TinyJS provides a simple yet powerful utility for developers looking to enhance their web applications with dynamic HTML element creation.

  • Thursday, October 3, 2024

    TinyJS is a lightweight JavaScript library designed to simplify the process of dynamically creating HTML elements. It allows developers to generate standard HTML tags programmatically, making DOM manipulation more straightforward and efficient. The library supports deep property assignment, enabling users to work with nested property structures for more complex elements. One of the key features of TinyJS is its ability to dynamically create HTML elements. Users can generate any standard HTML tag with ease, apply properties, and append content, whether it be strings or other elements. Additionally, TinyJS provides convenient functions for selecting DOM elements, using `$` for single selections and `$$()` for multiple selections. The library operates by attaching functions for each HTML tag to the global window object. This means that developers can create elements simply by calling the tag name as a function, passing in optional properties and child elements. For example, to create a `div` with specific attributes and child elements, one can use a syntax that resembles native JavaScript but is more concise and intuitive. TinyJS also includes helper functions that enhance its usability. The `$` function acts as a wrapper around `document.querySelector`, allowing for easy selection of a single DOM element, while `$$()` wraps `document.querySelectorAll`, returning an array of elements for easy iteration. An example of using TinyJS might involve creating a `div` that contains an `h1` and a `p` element. This is done by calling the respective tag functions and passing in the desired properties and content. The created elements can then be appended to the document body or any other parent element. Installation of TinyJS is straightforward; developers simply need to include the `tiny.js` script in their project. Once included, they can utilize any valid HTML tag as a function to create elements, assign properties, and append children to the DOM. The library supports a wide range of HTML tags, including basic text elements like `p` and `span`, interactive elements such as `button` and `input`, media elements like `img` and `video`, and various container elements including `div` and `section`. For those interested in contributing to TinyJS, the repository encourages users to open an issue before submitting a pull request, fostering a collaborative development environment. Overall, TinyJS offers a powerful yet simple solution for developers looking to enhance their web applications with dynamic HTML element creation.

  • Thursday, August 15, 2024

    You can speed up client-side rendered apps by preloading the necessary page chunks before they're needed, avoiding delays caused by lazy loading. By injecting a small script during the build process, you can make sure that route-specific chunks load in parallel with the app's entry point.

    Hi Impact
  • Tuesday, June 25, 2024

    The Google AI JavaScript SDK allows developers to utilize Google's generative AI models like Gemini for various applications, such as text and image generation, and chat interactions.

  • Friday, April 19, 2024

    Developers share their web dev “hacks” and stories. One developer improved a slow SQL scheduling algorithm by refactoring the code and converting sub-selects to joins. Others found creative ways to work around limitations in older web tech, like using system commands for a school prank or inventing a precursor to AJAX for a chat application.

  • Tuesday, March 12, 2024

    Streaming HTML sends HTML from server to browser in chunks as it is generated. It took a back seat as single-page applications became the standard, but it has become more popular along with server-side rendering. A clear advantage to streaming HTML is you can render something immediately to indicate to the user that something is happening and you can start downloading assets like CSS and JavaScript earlier while you wait for the more time-consuming parts of the response to be generated.